from starlette_admin import EnumField
from starlette_admin.contrib.sqla import ModelView

from src.application.order.enums import OrderPeriod, OrderStatus, OrderType
from src.infrastructure.db.models import Order


class OrderView(ModelView):
    fields = [
        "id",
        EnumField("status", enum=OrderStatus, select2=False),
        EnumField("type", enum=OrderType, select2=False),
        "summ",
        "summ_total",
        "was_created",
        "auto_renew",
        EnumField("period", enum=OrderPeriod, select2=False),
        "expiring_on",
        "was_renewed",
        "site",
        "user",
        "proxies",
        "last_notified",
    ]
    fields_default_sort = [Order.id, ("id", True)]
